package com.fqgj.report.statistics.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.report.statistics.dao.BiRuleStatDao;
import com.fqgj.report.statistics.entity.BiRuleStatEntity;
import com.fqgj.report.statistics.entity.BiRuleStatisticEntity;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: ykpbean
 * Date: 2017-10-18
 * Time: 14:28:32.034
 */

@Repository
public class BiRuleStatDaoImpl extends AbstractBaseMapper<BiRuleStatEntity> implements BiRuleStatDao {

    @Autowired
    @Qualifier("sqlSessionFactory2")
    private SqlSessionFactory sqlSessionFactory;

    public List<BiRuleStatisticEntity> selectRiskRuleStatistic(String startDate, String endDate, Long eventId,
                                                               String executorType, String version,
                                                               String source, Integer borrowType, Integer resultType) {
        Map<String, Object> param = new HashMap<>();
        param.put("startDate", startDate);
        param.put("endDate", endDate);
        param.put("eventId", eventId);
        param.put("executorType", executorType);
        param.put("version", version);
        param.put("source", source);
        param.put("borrowType", borrowType);
        param.put("resultType", resultType);
        SqlSession sqlSession = new SqlSessionTemplate(sqlSessionFactory);

        return sqlSession.selectList(getStatement(".selectRiskRuleStatistic"), param);
    }

}